package com.wwtech.epp.utils;

import android.content.Context;
import android.widget.TextView;

import com.wwtech.epp.R;

import java.util.Calendar;

/**
 * 作者：Android on 2017/9/22
 * 邮箱：365941593@qq.com
 * 描述：
 */

public class WorkUtil {
    public static String idParse2Type(int id) {
        switch (id) {
            case 6:
                return "请假";
            case 7:
                return "公告通知";
            case 8:
                return "外出";
            case 9:
                return "日报";
            case 10:
                return "外出";
            case 11:
                return "月报";
            case 12:
                return "出差审批";
            case 13:
                return "用车审批";
            case 14:
                return "加班审批";
            case 15:
                return "借款审批";
            case 16:
                return "采购审批";
            case 17:
                return "日程提醒";
            case 22:
                return "工资审批";
        }
        return "";
    }

    //1工作中，2出差中，3请假中，4生病中，5会议中，6休假中
    public static int workStatusParse(String workStatus) {
        switch (workStatus) {
            case "工作中":
                return 1;
            case "出差中":
                return 2;
            case "请假中":
                return 3;
            case "生病中":
                return 4;
            case "会议中":
                return 5;
            case "休假中":
                return 6;
            default:
                return 1;
        }
    }
    //1工作中，2出差中，3请假中，4生病中，5会议中，6休假中
    public static String workStatusParse(int workStatus) {
        switch (workStatus) {
            case 1:
                return "工作中";
            case 2:
                return "出差中";
            case 3:
                return "请假中";
            case 4:
                return "生病中";
            case 5:
                return "会议中";
            case 6:
                return "休假中";
            default:
                return "工作中";
        }
    }

    public static void approveStateParse(Context context, int state, TextView textView) {
        switch (state) {
            case -1:
                textView.setText("已撤销");
                break;
            case 0:
                textView.setTextColor(context.getResources().getColor(R.color.main_color));
                textView.setText("审批中");
                break;
            case 1:
                textView.setTextColor(context.getResources().getColor(R.color.color_2ba245));
                textView.setText("审批通过");
                break;
            case 2:
                textView.setTextColor(context.getResources().getColor(R.color.color_f51818));
                textView.setText("已拒绝");
                break;
            case 3:
                textView.setText("审批超时");
                break;
        }
    }

    public static void approveStateParse(Context context, int state, TextView textView, String nickName) {
        switch (state) {
            case -1:
                textView.setText("已撤销");
                break;
            case 0:
                textView.setTextColor(context.getResources().getColor(R.color.main_color));
                textView.setText("等待" + nickName + "审批中");
                break;
            case 1:
                textView.setTextColor(context.getResources().getColor(R.color.color_2ba245));
                textView.setText("审批通过");
                break;
            case 2:
                textView.setTextColor(context.getResources().getColor(R.color.color_f51818));
                textView.setText("已拒绝");
                break;
            case 3:
                textView.setText("审批超时");
                break;
        }
    }

    /**
     * 判断任务是否过期
     */
    public static int isUnValuableTask(String date) {
        long oneday = 24 * 60 * 60 * 1000;
        long remainTimeMillis = TimeUtil.timeStamp(date) - Calendar.getInstance().getTimeInMillis();
        if (remainTimeMillis >= 0) {
            return -1;
        } else {
            return (int) (Math.abs(remainTimeMillis) / oneday);
        }
    }
}
